#include <assert.h>
#include <string>
#include <cstdlib>

using namespace std;

void runStringTest()
{
	// --------------------

    string a("a");
	string a2('a');
	string a3(a);

	log(a.c_str());
	log(a2.c_str());
	log(a3.c_str());

	assert(a == a);
	assert(a == a2);
	assert(a == a3);

	// --------------------

	a = a + "a";
	a2 = a2 + 'a';
	a3 = a3 + a3;

	log(a.c_str());
	log(a2.c_str());
	log(a3.c_str());

	assert(a == a);
	assert(a == a2);
	assert(a == a3);

	// --------------------

	a += "a";
	a2 += 'a';
	a3 += string("a");

	log(a.c_str());
	log(a2.c_str());
	log(a3.c_str());

	assert(a == a);
	assert(a == a2);
	assert(a == a3);

	// --------------------

	string b;
	string b2;
	string b3;

	b = "b";
	b2 = 'b';
	b3 = b;

	log(b.c_str());
	log(b2.c_str());
	log(b3.c_str());

	assert(b == b);
	assert(b == b2);
	assert(b == b3);

	// --------------------

	string text = "Hello there!";

	size_t pos = text.find("the");
	assert(6 == pos);

	pos = text.find("x");
	assert(string::npos == pos);

	// --------------------

	log("Tests passed");
}
